let swiperImgUrls = require("../../data/swiper")
let songs = require("../../data/songs")
let LIMIT = 9;
Page({
    data: {
        swiperImgUrls: [],
        songs: [],
    },
    getPlayList() {
        wx.showLoading({
            title: '加载中...',
        })
        wx.cloud.callFunction({
            name: "music",
            data: {
                start: this.data.songs.length,
                count: LIMIT,
                $url: "getPlayListData"
            }
        }).then(res => {
            this.setData({
                songs: this.data.songs.concat(res.result)
            })
            wx.hideLoading()
        })
        wx.stopPullDownRefresh()
    },
    onLoad() {
        this.setData({
            swiperImgUrls: swiperImgUrls,
            // songs: songs
        })
        this.getPlayList();
    },
    // 当你上拉时触发
    onReachBottom() {
        this.getPlayList();
    },
    // 当下拉时触发
    onPullDownRefresh() {
        this.setData({
            songs: []
        })
        this.getPlayList();
    }
})